%::PROVIDES=(
	name	=> ["STOPPED_APP"],
	desc	=> ["Application Stopped actions"],
	type	=> "request",
	code	=> \&::do_handle_stoppedapp
);

#########################################################################
# Here we check if the monitor is running and we have a lems port 	#
# if so we send it a request to abort monitoring before stopping the	#
# application.								#
#########################################################################

sub ::do_handle_stoppedapp {
my $args=shift;
my ($app,$h);
my ($lems_client,$lems_response);

	if(!exists($args->{APP})) {
		logwarn("STOPPED_APP request missing APP argument");
		return "MISSING_ARG";
	}

	$h=hostname;
	$app=$args->{APP};
	if(!exists($appmap->{$app})) {
		logwarn("Specified application is not registered");
		return "NOT_REGISTERED";
	}

	$appmap->{$app}->{STATE}="DOWN";
	$appmap->{$app}->{NODE}=".";
	$appmap->{$app}->{STARTTIME}=0;
	$appmap->{$app}->{MONITOR}=0;
	$h=hostname;
	queue_it("APP_UPDATE app=$app state=DOWN node=$h starttime=0");
	return "OK";
}

1;

